﻿using System.Collections.Generic;
using IDAL;
using NHibernate;

namespace SqlDALLibrary
{
    public class ActionDal : IActionDAL
    {
        private static EntityControl control;

        static ActionDal()
        {
            control = EntityControl.CreateEntityControl("Model");
        }

        public Model.Action getAction(int id)
        {
            NHibernateHelper nh = new NHibernateHelper();
            ISession session = nh.GetSession();
            Model.Action action = session
                    .CreateQuery("from Action a where a.id=:id")
                    .SetInt32("id", id)
                    .UniqueResult<Model.Action>();
            session.Close();
            return action;
        }

        public IList<Model.Action> getAction()
        {
            NHibernateHelper nh = new NHibernateHelper();
            ISession session = nh.GetSession();
            IList<Model.Action> actionList = session.CreateQuery("from Action")
                        .List<Model.Action>();
            session.Close();
            return actionList;
        }

    }
}
